//
//  SLTabBarController.h
//  SLTabBarVc+NavigationVc
//
//  Created by 伟仔c on 15/3/2.
//  Copyright (c) 2015年 SL. All rights reserved.
//

#import "SLNavigationController.h"

@interface SLNavigationController ()

@end

@implementation SLNavigationController

#pragma mark -第一次使用这个类
+ (void)initialize {
    
    // 1.设置导航条的字体样式
    [self setupBarButtonItemTheme];
}

#pragma mark -设置导航条的字体样式
+ (void)setupBarButtonItemTheme {

    // 1.设置导航条的字体样式
    UIBarButtonItem *barButtonItem = [UIBarButtonItem appearance];
    
    // 1.1 普通状态
    NSMutableDictionary *itemDict = [NSMutableDictionary dictionary];
    itemDict[NSFontAttributeName] = [UIFont systemFontOfSize:20];   // 字体大小
    itemDict[NSForegroundColorAttributeName] = [UIColor redColor]; // 字体颜色
    [barButtonItem setTitleTextAttributes:itemDict forState:UIControlStateNormal];
    
    // 1.2 高亮状态
    NSMutableDictionary *itemHighDict = [NSMutableDictionary dictionary];
    itemHighDict[NSForegroundColorAttributeName] = [UIColor orangeColor]; // 字体颜色
    [barButtonItem setTitleTextAttributes:itemHighDict forState:UIControlStateHighlighted];
    
    // 1.3 不可用状态
    NSMutableDictionary *buttonItemDisaDict = [NSMutableDictionary dictionary];
    buttonItemDisaDict[NSForegroundColorAttributeName] = [UIColor lightGrayColor]; // 字体颜色
    [barButtonItem setTitleTextAttributes:buttonItemDisaDict forState:UIControlStateDisabled];
    
    
    // 2.设置导航条的样式
    UINavigationBar *navigationBar = [UINavigationBar appearance];
    NSMutableDictionary *navigationBarDict = [NSMutableDictionary dictionary];
    navigationBarDict[NSForegroundColorAttributeName] = [UIColor whiteColor]; // 字体颜色
    navigationBarDict[NSFontAttributeName] = [UIFont boldSystemFontOfSize:25]; // 字体大小
    [navigationBar setTitleTextAttributes:navigationBarDict];

    // 2.1 设置背景图片
    UIImage *backgroundImage = nil; // 背景图文件名
    [navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
}

#pragma mark -拦截push方法
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.viewControllers.count > 0) {
        // 1.隐藏底部TabBar
        viewController.hidesBottomBarWhenPushed = YES;
        
        // 2.默认的Back按钮
//        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"NavBack"] style:UIBarButtonItemStyleDone target:self action:@selector(popViewControllerAnimated:)];
        
    }
    [super pushViewController:viewController animated:animated];
}

@end
